import threading
import time
class A(object):
    def test(self):
        while True:
            print("i am a dead loop")
            time.sleep(1)

def del_dead_loop(a):
    for i in range(100):
        print(i)
        if  i == 50:
            a.stop()
a = A()
thread = threading.current_thread()
thread.join()
threading.Thread(target=del_dead_loop, args=(a,)).start()
a.test()
